/* ***************************************************************************
 * EZ.JWAF/EZ.JCWAP: Easy series Production.
 * Including JWAF(Java-based Web Application Framework)
 * and JCWAP(Java-based Customized Web Application Platform).
 * Copyright (C) 2016-2017 the original author or authors.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of MIT License as published by
 * the Free Software Foundation;
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the MIT License for more details.
 *
 * You should have received a copy of the MIT License along
 * with this library; if not, write to the Free Software Foundation.
 * ***************************************************************************/

package com.lee.jcwap.dict.service;

import java.util.List;

import com.lee.jcwap.dict.entity.SysDict;
import com.lee.jwaf.exception.ServiceException;

/**
 * ClassName : DictService <br>
 * Description : Operation service of SysDict <br>
 * Create Time : 2016-09-23 <br>
 * @author jimmyblylee@126.com
 */
@SuppressWarnings("unused")
public interface DictService {

    /* ************************
     * for JEE support
     * ************************/
    /** JNDI name. */
    String NAME = "dict-service/DictService";
    /** JNDI name. */
    String JNDI = NAME + "/remote";

    /* ***********************
     * simple operation for CREATE REMOVE UPDATE
     * ***********************/
    /**
     * Description : create SysDict by given dict <br>
     *     default: isEnabled = true, isSysDefined = true, pinyin will be filled with the value
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param dict the dict entity
     * @return the entity created with filling infos: id, pinyin, enabled(true as default)
     * @throws Exception dict is null, or validation failed
     */
    SysDict createDictionary(SysDict dict) throws Exception;

    /**
     * Description : create SysDict by given list<br>
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param dictList the list of dict
     * @throws ServiceException dictList is null or there are some entity can not pass the validation
     */
    void createDictionary(List<SysDict> dictList) throws ServiceException;

    /**
     * Description : remove SysDict by given id <br>
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param dictId the dictId
     * @throws ServiceException given id is null or could not find SysDict by given id
     */
    void removeDictionariesById(Integer dictId) throws ServiceException;

    /**
     * Description : remove SysDict by given ids <br>
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param dictIds the dictId
     * @throws ServiceException given id is null or could not find SysDict by given id
     */
    void removeDictionariesById(List<Integer> dictIds) throws ServiceException;

    /**
     * Description : remove SysDict by given nature <br>
     * Create Time: Apr 14, 2016 <br>
     * Create by : xiangyu_li@asdc.com.cn <br>
     *
     * @param nature dict nature
     * @return count of removed dicts
     * @throws ServiceException nature is null
     */
    int removeDictionaryByNature(String nature) throws ServiceException;

    /**
     * Description : udpate SysDict by given dict<br>
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param dict the dict
     * @return the updated SysDict with new pinyin generated by given value of SysDict
     * @throws ServiceException dict is null or entity validation failed
     */
    SysDict updateDictionary(SysDict dict) throws ServiceException;

    /**
     * Description : udpate SysDict by given dicts <br>
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param dicts the dict
     * @return the updated SysDict with new pinyin generated by given value of SysDict
     * @throws ServiceException dict is null or entity validation failed
     */
    List<SysDict> updateDictionary(List<SysDict> dicts) throws ServiceException;

    /* ***********************
     * query
     * ***********************/
    /**
     * Description : get the SysDict by given nature string and code string <br>
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param nature dict nature
     * @param code dict code
     * @return the entity of SysDict with given nature and code
     * @throws ServiceException if nature or code is null
     */
    SysDict getDictByNatureAndCode(String nature, String code) throws ServiceException;

    /**
     * Description : query SysDict by condition which is an instance of SysDIct,
     * and fileds with value will be a condition will search by "like" <br>
     * for parent and children search condition, only support parent "nature" condition<br>
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param condition SysDict condition
     * @param start page start
     * @param limit -1 for skipping page limit, and return all the SysDict
     * @return list of SysDict
     * @throws ServiceException condition is null
     */
    @SuppressWarnings("SameParameterValue")
    List<SysDict> querySysDict(SysDict condition, int start, int limit) throws ServiceException;

    /**
     * Description : query SysDict by condition which is an instance of SysDIct,
     * and fileds with value will be a condition will search by "like" <br>
     * for parent and children search condition, only support parent "nature" condition<br>
     * Create Time: 2016-09-23 <br>
     * Create by : jimmyblylee@126.com <br>
     *
     * @param condition SysDict condition
     * @return count of result
     * @throws ServiceException condition is null
     */
    Integer getCount(SysDict condition) throws ServiceException;

    /** JEE Remote Service. */
    interface Remote extends DictService { }

    /** JEE Local Service. */
    interface Local extends DictService { }
}
